#include <opencv2/opencv.hpp>

using namespace cv;

int main()
{
    VideoCapture camera;
    VideoWriter writer;

    camera.open(0);
    //获取帧大小
    Size size = Size(camera.get(CAP_PROP_FRAME_WIDTH), camera.get(CAP_PROP_FRAME_HEIGHT));
    //获取帧率
    double fps = camera.get(CAP_PROP_FPS);
    //打开文件
    writer.open("record.avi", VideoWriter::fourcc('M','J','P','G'), fps, size);

    Mat frame;
    while(1)
    {
        camera >> frame;
        writer << frame;
    }
}
